package com.guoxin.artconcurrency.chapter8;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

/**
 * CyclicBarrierTest 测试
 *
 * @author guoxin
 * @date 2019/8/6
 */
public class CyclicBarrierTest {
    private static CyclicBarrier cb = new CyclicBarrier(2);

    public static void main(String[] args) throws BrokenBarrierException, InterruptedException {
        new Thread(() -> {
            try {
                cb.await();
            } catch (InterruptedException | BrokenBarrierException e) {
                e.printStackTrace();
            }
            System.out.println(1);
        }).start();

        cb.await();
        System.out.println(2);
    }
}
